package main

import (
	"github.com/gin-gonic/gin"
	"project2/controller/AppFunController"
	"project2/controller/SysAccountController"
	"project2/controller/SysClassController"
	"project2/controller/SysDicController"
	"project2/controller/SysRoleController"
	"project2/db"
)

func main() {

	//初始化数据库
	db.InitDb()

	r := gin.Default()
	r.Delims("${", "}")
	r.LoadHTMLGlob("./views/*")
	r.Use(gin.Logger(), gin.Recovery())

	r.Static("/static", "./static")

	r.GET("/login", func(ctx *gin.Context) {
		ctx.HTML(200, "login.html", gin.H{})
	})

	r.GET("/ping", func(ctx *gin.Context) {
		ctx.JSON(200, gin.H{"ping": "pong"})
	})

	r.GET("/post", func(ctx *gin.Context) {
		ctx.HTML(200, "register.html", gin.H{})
	})

	r.POST("/login", func(ctx *gin.Context) {
	})

	SysClassController.InitRoutes(r)
	SysAccountController.InitRoutes(r)
	AppFunController.InitRoutes(r)
	SysDicController.InitRoutes(r)
	SysRoleController.InitRoutes(r)

	r.Run(":8081")
	print("8081")
}
